package com.demo.uid.controller;

import com.demo.uid.properties.UidGroupProperties;
import com.demo.uid.service.SnowFlakeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class SnowFlakeController {

    @Resource
    private SnowFlakeService snowFlakeService;

    @Resource
    private UidGroupProperties uidGroupProperties;

    @GetMapping("/getId")
    public Long getId(@RequestParam("prefix") String prefix, @RequestParam("biz") String biz) {
        return snowFlakeService.getId(prefix, biz);
    }

    @GetMapping("/getGlobalId")
    public Long getGlobalId() {
        return snowFlakeService.getGlobalId();
    }

    @GetMapping("/getConfig")
    public String getConfig() {
        return uidGroupProperties.getMap().toString();
    }
}
